#!/usr/bin/env python  
# -*- coding: utf-8 -*-  
"""  
@author: ઈ一笑ഒ 
@time: 2024/7/13 11:55  
@file: forms.py  
@project: mysite1
@describe: TODO  
"""
from django import forms

class LoginForm(forms.Form):
    name = forms.CharField(label='name', max_length=20)
    email = forms.EmailField(label='email')
    password = forms.CharField(label='password', widget=forms.PasswordInput)



class RegisterForm(forms.Form):
    name = forms.CharField(label='name',max_length=5)
    email = forms.EmailField(label='email')
    password = forms.CharField(label='password', widget=forms.PasswordInput)
    confirm_password = forms.CharField(label='confirm_password', widget=forms.PasswordInput)


    def clean(self):
        cleaned_data = super().clean()
        password = cleaned_data.get('password')
        confirm_password = cleaned_data.get('confirm_password')

        if password and confirm_password and password != confirm_password:
            raise forms.ValidationError('Passwords do not match.')
